package es.ats.codington.festival.utils;

import java.sql.Connection;
import java.sql.DriverManager;



public class FERSConnectionToDB {
	
	static Connection conn;
	
	public static Connection getConnection(){
	/**
		private static Connection conn = null;
	
	 public static Conn createConnection() throws ClassNotFoundException, SQLException {
		 Class.forName("com.mysql.jdbc.Driver");
		 conn = DriveManager.getConnection(
				 "jdbc:mysql://localhost/codingtonred","root","abcd1234");
		 return connection;
	 }
	 
	 public static void closeConnection() throws SQLException {
		 conexion.close();
	 }
	 
	 */
		
		try{
			String url = "jdbc:mysql://localhost/codingtonred";
			String user = "root";
			String pass = "abcd1234";
			
			//Loading the driver
			Class.forName("com.mysql.jdbc.Driver");
			
			//Obtaining a connection using DriverManager class
			conn = DriverManager.getConnection(url, user, pass);
			
		}catch(Exception e){
			System.out.println(e.getMessage());
		}
		
		return conn;
	}
	
	public static void main(String[] args) {
		getConnection();
		System.out.println("Connection obtained - " + conn);
	}

}
